package AgentTravel.LogicObjects;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import AgentTravel.gui.AbstractModelObject;

public class KnownLanguages extends AbstractModelObject implements Serializable
{
	private static final long serialVersionUID = -7722199844256785134L;
	private List<Language> m_languages;

	public KnownLanguages(Collection<Language> languages)
	{
		if(languages == null)
			throw new NullPointerException("collection of known languages cannot be null!");
		m_languages = new ArrayList<Language>(languages);
	}
	/**
	 * @return the m_languages
	 */
	public List<Language> getLanguages() {
		return m_languages;
	}

	public void addLanguage(Language language) {
		if(m_languages.contains(language))
			return;
		List<Language> oldValue = m_languages;
		m_languages = new ArrayList<Language>(m_languages);
		m_languages.add(language);
		firePropertyChange("languages", oldValue, m_languages);
	}

	public void removeLanguage(Language language) {
		List<Language> oldValue = m_languages;
		m_languages = new ArrayList<Language>(m_languages);
		m_languages.remove(language);
		firePropertyChange("languages", oldValue, m_languages);
	}

}

